#encoding='gbk'

import unittest
import requests
import random
import time


class Test(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.url= 'httP://101.42.247.45:8080'
        self.num= random.randint(1000,999999)
        pass
    def test_register(self):
        url= self.url+'/register/'
        data = '{"username":"abc1%s","password":"a12345678","email":"lily@qq.com"}' % str(self.num)
        req= requests.post(url=url,data=data)
        print(1,req.text)
        assert '00' in req.text
        pass

    def test_login(self):
        url= self.url+'/login/'
        data = '{"username":"abc1%s","password":"e9bc0e13a8a16cbb07b175d92a113126"}' % str(self.num)
        req= requests.post(url=url,data=data)
        print(2,req.text)
        assert 'token' in req.text
    def tearDown(self):
        print(3,'一个测试用例执结束')

if __name__=='__main__':
    unittest.main()